<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
// 前台路由组
Route::group(['namespace'=>'Home','as'=>'home.'],function(){
    // 前台页面路由
    Route::get('/','HomeController@index')->name('index');
    Route::get('/lists/{category}/{attrs?}','HomeController@lists')->name('lists');
    Route::get('/content/{goods}','HomeController@content')->name('content');
    Route::get('/huopin/{attr}/{goods}','HomeController@getHuopin');

    // 登录路由
    Route::get('/loginPage','UserController@loginPage')->name('loginPage');
    Route::post('/login','UserController@login')->name('login');
    // 注册路由
    Route::get('/register','UserController@register')->name('register');
    Route::post('/store','UserController@store')->name('store');
    // 退出路由
    Route::get('/logout','UserController@logout')->name('logout');


});
Route::group(['namespace'=>'Home','as'=>'home.','middleware'=>'home.user'],function(){

    // 用户信息
    Route::get('/user/index','InformationController@index')->name('user.index');
    Route::get('/user/info','InformationController@info')->name('user.info');
    Route::get('/user/icon','InformationController@icon')->name('user.icon');
    Route::get('/user/more','InformationController@moreinfo')->name('user.moreinfo');
    Route::resource('/address','AddressController');
    Route::get('/setDefault/{address}','AddressController@setDefault')->name('setDefault');
    Route::get('/collection/{goods}','CollectionController@collect')->name('collection');
    Route::get('/collect','CollectionController@mycollect')->name('collect');
});



// 后台路由
Route::group(['prefix'=>'admin','namespace'=>'Admin','as'=>'admin.','middleware'=>'admin.auth'],function(){
    // 首页路由
    Route::get('/','AdminController@index')->name('admin');
    // 退出路由
    Route::get('/logout','LoginController@logout')->name('logout');
});
// 后台登录路由
Route::group(['prefix'=>'admin','namespace'=>'Admin','as'=>'admin.'],function(){
    // 加载登录界面
    Route::get('/login','LoginController@loginForm')->name('login');
    // 验证登录
    Route::post('/login','LoginController@login')->name('login');
});
// 属性路由
Route::group(['prefix'=>'attr','namespace'=>'Attr','as'=>'attr.','middleware'=>'admin.auth'],function(){
    Route::resource('/attr','AttrController');
});
// 分类管理路由
Route::group(['prefix'=>'category','namespace'=>'Category','as'=>'category.','middleware'=>'admin.auth'],function(){
    Route::resource('/category','CategoryController');
    // 获取子分类路由
    Route::get('/getSon/{category}','CategoryController@getSon')->name('getSon');
    // 获取子属性路由
    Route::get('/getAttrs/{category}','CategoryController@getAttrs')->name('getAttrs');
});
// 用户管理路由
Route::group(['prefix'=>'goods','namespace'=>'Goods','as'=>'goods.','middleware'=>'admin.auth'],function(){
    Route::resource('/goods','GoodsController');
    Route::resource('/huopin','HuopinController');
});
// 工具路由组
Route::group(['prefix'=>'util','namespace'=>'Util','as'=>'util.'],function(){
    Route::any('/upload','UploadController@upload')->name('upload');
    Route::any('/lists','UploadController@lists')->name('lists');
    Route::get('/send/{account}','CodeController@send')->name('send');
});

// 后台用户信息路由
Route::group(['prefix'=>'adminuser','namespace'=>'AdminUser','as'=>'adminuser.'],function(){
    Route::get('/icon','AdminUserController@icon')->name('icon');
    Route::post('updateicon','AdminUserController@updateIcon')->name('updateIcon');
    Route::get('/password','AdminUserController@password')->name('password');
    Route::post('/changepassword','AdminUserController@changePassword')->name('changePassword');
});

// 购物车路由
Route::group(['prefix'=>'cart','namespace'=>'Cart','as'=>'cart.','middleware'=>'home.user'],function(){
    // 加入购物车路由
    Route::get('/addCart/{goods_id}/{huopin_id}/{num}','CartController@addCart')->name('addCart');
    // 购物车列表路由
    Route::get('/cartList','CartController@cartList')->name('cartList');
    // 改变购物车数量路由
    Route::get('/changeNum/{type}/{cart}','CartController@changeNum')->name('changeNum');
    // 删除一条商品
    Route::get('/deleteCart/{cart}','CartController@deleteCart')->name('deleteCart');
    // 批量删除商品
    Route::get('/deleteMany/{ids}','CartController@deleteMany')->name('deleteMany');
    // 购物车展示路由
    Route::get('/show/{goods_id}/{huopin_id}/{num}','CartController@show')->name('show');
    // 支付跳转路由
    Route::get('/jiesuan/{ids}/{total}','CartController@jiesuan')->name('jiesuan');
});
    // 订单路由
Route::group(['prefix'=>'order','namespace'=>'Order','as'=>'order.'],function(){
    Route::get('/addOrder/{ids}','OrderController@addOrder')->name('addOrder');
    Route::get('/pay/{order}','OrderController@pay')->name('pay');
    Route::get('/checkStatus/{orderId}','OrderController@checkStatus')->name('checkStatus');
    Route::get('/success','OrderController@success')->name('success');

    Route::get('/myOrder','OrderController@myOrder')->name('myOrder');
    Route::get('/orderList/{order}','OrderController@orderList')->name('orderList');
});

// 微信支付回调通知路由
Route::any('/weixinpay/notify','Order\OrderController@notify');



